package xdpm.nhom16.GUI;

import xdpm.nhom16.R;
import xdpm.nhom16.BUS.BUSProvider;
import xdpm.nhom16.BUS.SearchEngine;
import xdpm.nhom16.helper.Utilities;
import android.app.Activity;
import android.os.Bundle;

import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;

import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;

public class MenuDiaDiem extends Activity
{
	/** Called when the activity is first created. */
	private AutoCompleteTextView txtSearch;
	private ImageButton imageButtonSearch;
	private SearchEngine searchEng;
	
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.listview_menu);
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title_search);
		
		
		txtSearch = (AutoCompleteTextView) findViewById(R.id.edittextQuerySearch);
		Autocomplete auto = new Autocomplete(txtSearch, searchEng, this);
		auto.test();
		
		Bundle mBundle = new Bundle();
		mBundle = getIntent().getExtras();
		int iMaDuLieu = mBundle.getInt("MaDuLieu");
		String tenDiaDiem = mBundle.getString("TenDiaDiem");
		TextView txtTenDiaDiem = (TextView) findViewById(R.id.textMenuTenDiaDiem);
		txtTenDiaDiem.setText("Menu - " + tenDiaDiem);
		ListView listViewMenu = (ListView) findViewById(R.id.listViewMenu);
		listViewMenu.setAdapter(BUSProvider.getMenuAdapter(iMaDuLieu, this));
		
		imageButtonSearch = (ImageButton) findViewById(R.id.imageButtonSearch);
		imageButtonSearch.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				onClickSearchButton();
			}
		});
	}

	public void onClickSearchButton()	{
		Utilities.onClickButtonSearch(txtSearch.getText().toString(), this);
	}
}